package com.xx.happychatboot.middleware.rocketmq.domain.entity;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.xx.happychatboot.middleware.rocketmq.domain.dto.SecureInvokeDTO;
import io.mybatis.provider.Entity;
import lombok.*;

/**
 * <p>
 * 本地消息表
 * </p>
 *
 * @author xiaoXuan
 * @since 2025-01-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity.Table(value = "secure_invoke_record",autoResultMap = true)
public class SecureInvokeRecord implements Serializable {
    public final static byte STATUS_WAIT = 1;
    public final static byte STATUS_FAIL = 2;

    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Entity.Column(id = true, remark = "主键", updatable = false, insertable = false)
    private Long id;

    /**
     * 请求快照参数json
     */
    @Entity.Column(value = "secure_invoke_json",typeHandler = JacksonTypeHandler.class)
    private SecureInvokeDTO secureInvokeDTO;

    /**
     * 状态 1待执行 2已失败
     */
    @Entity.Column("status")
    @Builder.Default
    private byte status = SecureInvokeRecord.STATUS_WAIT;

    /**
     * 下一次重试的时间
     */
    @Entity.Column("next_retry_time")
    @Builder.Default
    private Date nextRetryTime = new Date();

    /**
     * 已经重试的次数
     */
    @Entity.Column("retry_times")
    @Builder.Default
    private Integer retryTimes = 0;

    /**
     * 最大重试次数
     */
    @Entity.Column("max_retry_times")
    private Integer maxRetryTimes;

    /**
     * 执行失败的堆栈
     */
    @Entity.Column("fail_reason")
    private String failReason;

    /**
     * 创建时间
     */
    @Entity.Column("create_time")
    @Builder.Default
    private Date createTime = new Date();

    /**
     * 修改时间
     */
    @Entity.Column("update_time")
    @Builder.Default
    private Date updateTime = new Date();


}
